
module libeventd.Util ;

import libeventd.Types;

extern(C):

version(_EVENT_HAVE_STRUCT_ADDRINFO){
	alias addrinfo evutil_addrinfo;
}else{
	struct evutil_addrinfo {
		ev_int	ai_flags;
		ev_int	ai_family;
		ev_int	ai_socktype;
		ev_int	ai_protocol;
		size_t	ai_addrlen;
		char*	ai_canonname;
		sockaddr*	ai_addr;
		evutil_addrinfo*	ai_next;
	}
}

ev_int evutil_socketpair(ev_int d, ev_int type, ev_int protocol, evutil_socket_t sv[2]);
ev_int evutil_make_socket_nonblocking(evutil_socket_t sock);
ev_int evutil_make_listen_socket_reuseable(evutil_socket_t sock);
ev_int evutil_make_socket_closeonexec(evutil_socket_t sock);
ev_int evutil_closesocket(evutil_socket_t sock);
alias evutil_closesocket EVUTIL_CLOSESOCKET;
version(Windows){
ev_int evutil_socket_geterror(evutil_socket_t sock);
char *evutil_socket_error_to_string(ev_int errcode);
}
ev_int64_t evutil_strtoll( char *s, char **endptr, ev_int base);
ev_int evutil_snprintf(char *buf, size_t buflen,  char *format, ...);
ev_int evutil_vsnprintf(char *buf, size_t buflen,  char *format, /*va_list */ ... );
char *evutil_inet_ntop(ev_int af,  void *src, char *dst, size_t len);
ev_int evutil_inet_pton(ev_int af,  char *src, void *dst);
ev_int evutil_parse_sockaddr_port( char *str,  sockaddr*, ev_int *outlen);
ev_int evutil_sockaddr_cmp(  sockaddr *sa1,   sockaddr*sa2, ev_int include_port);
ev_int evutil_ascii_strcasecmp( char *str1,  char *str2);
ev_int evutil_ascii_strncasecmp( char *str1,  char *str2, size_t n);
ev_int evutil_getaddrinfo( char *nodename,  char *servname,evutil_addrinfo *hints_in,  evutil_addrinfo **res);
void evutil_freeaddrinfo( evutil_addrinfo *ai);
 char *evutil_gai_strerror(ev_int err);
void evutil_secure_rng_get_bytes(void *buf, size_t n);
ev_int evutil_secure_rng_init();
void evutil_secure_rng_add_bytes( char *dat, size_t datlen);
